package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import androidx.annotation.NonNull;

public class eqe {
    public static boolean ॱ() {
        try {
            Class cls = Class.forName("android.telephony.HwTelephonyManager");
            if (cls.getDeclaredField("SUPPORT_SYSTEMAPP_GET_DEVICEID").getInt(cls) == 1) {
                return true;
            }
            return false;
        } catch (NoSuchFieldException e) {
            Logger.e("PermissionExemptUtil", "support new Permission check, NoSuchFieldException error:" + e.toString());
            return false;
        } catch (IllegalAccessException e2) {
            Logger.e("PermissionExemptUtil", "support new Permission check, IllegalAccessException error:" + e2.toString());
            return false;
        } catch (IllegalArgumentException e3) {
            Logger.e("PermissionExemptUtil", "support new Permission check, IllegalArgumentException error:" + e3.toString());
            return false;
        } catch (ClassNotFoundException e4) {
            Logger.e("PermissionExemptUtil", "support new Permission check, IllegalArgumentException error:" + e4.toString());
            return false;
        } catch (Throwable e5) {
            Logger.ˋ("PermissionExemptUtil", "support new Permission check, other error", e5);
            return false;
        }
    }

    public static boolean ˎ(@NonNull Context context) {
        if (VERSION.SDK_INT < 23 || context.checkSelfPermission("android.permission.READ_PHONE_STATE") == 0) {
            return false;
        }
        boolean ॱ = ॱ();
        boolean ˊ = ˊ(context);
        boolean z = context.checkSelfPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") == 0;
        if (Logger.ˎ()) {
            Logger.ˏ("PermissionExemptUtil", "is Sys app:" + ˊ + ", support new permission check:" + ॱ + ", READ_PRIVILEGED_PHONE_STATE granted:" + z);
        }
        if (ॱ && (ˊ || z)) {
            return false;
        }
        return true;
    }

    private static boolean ˊ(@NonNull Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            if (packageInfo == null || packageInfo.applicationInfo == null || (packageInfo.applicationInfo.flags & 1) == 0) {
                return false;
            }
            return true;
        } catch (NameNotFoundException e) {
            Logger.e("PermissionExemptUtil", "can not find pkg");
            return false;
        }
    }
}
